import { defineComponent, onMounted, reactive } from 'vue'
import Draw from './draw'
import { device } from '@/public/request/http'

export default defineComponent({
  components: {
    Draw,
  },
  setup() {
    const cdata = reactive({
      seriesData: [],
    })

    // methods
    const setData = async () => {
      const res = await device()
      cdata.seriesData = []
      res.forEach(element => {
        cdata.seriesData.push({name:element.deviceTypeName,value:element.totalCount})
      });
    }

    onMounted(()=>{
      setData()
    })


    return () => {
      return (
        <div>
          <Draw cdata={cdata} />
        </div>
      )
    }
  },
})
